from dotenv.cli import enumerate_env
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import time
class config():
    def __init__(self,driver):
        self.driver = driver

    def open_url(self,url):
        self.driver.get(url)
    def find_element(self,loc):
        try:
            WebDriverWait(self.driver,20,1).until(lambda  driver:self.driver.find_element(*loc).is_displayed())

            return self.driver.find_element(*loc)
        except Exception as e:
            t = time.strftime('%Y_%m_%d_%H_%M_%S',time.localtime())
            self.driver.save_screenshot(t+'.png')
            return e


    def send_keys(self,loc,info):
        self.find_element(loc).send_keys(info)

    def click(self,loc):
        self.find_element(loc).click()

    def text(self,loc):
        return self.find_element(loc).text























